﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace MedicinesTrackerLibs
{
    public class Medicine
    {
        #region Attributes
        private int _intMilkWP, _intMeatWP;
        private String _strMedName;
        #endregion

        #region Constructor
        public Medicine()
        {
        }
        #endregion

        #region Properties
        public int MilkWithdrawalPeriod
        {
            get { return _intMilkWP; }
            set { _intMilkWP = value; }
        }

        public int MeatWithdrawalPeriod
        {
            get { return _intMeatWP; }
            set { _intMeatWP = value; }
        }

        public String MedicineName
        {
            get { return _strMedName; }
            set { _strMedName = value; }
        }
        #endregion

        #region Methods

        #endregion
    }

    public class MedicineViewModel : INotifyPropertyChanged
    {
        private Medicine _med;

        public MedicineViewModel()
        {
            _med = new Medicine{ MedicineName="Uknown", MeatWithdrawalPeriod=0, MilkWithdrawalPeriod=0 };
        }

        public String Medicine
        {
            get { return _med.MedicineName; }
            set
            {
                if (_med.MedicineName != value)
                {
                    _med.MedicineName = value;
                    RaisePropertyChanged("Medicine.Name");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
